package com.msb.serviceDriverUser.service;

import com.msb.internalcommon.dto.DriverUserWorkStatus;
import com.msb.internalcommon.dto.ResponseResult;
import com.msb.serviceDriverUser.mapper.DriverUserWorkStatusMapper;
import org.apache.tomcat.jni.Local;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务类
 * </p>
 *
 * @author jiudianliu
 * @since 2023-07-06
 */
@Service
public class DriverUserWorkStatusService {

    @Autowired
    DriverUserWorkStatusMapper driverUserWorkStatusMapper ;


    public ResponseResult changeWorkStatus( Long driverId , Integer workStatus) {
        LocalDateTime localDateTime = LocalDateTime.now();

        Map<String , Object> queryMap = new HashMap<>() ;
        queryMap.put("driver_id" , driverId) ;
        List<DriverUserWorkStatus> driverUserWorkStatuses = driverUserWorkStatusMapper.selectByMap(queryMap);
        DriverUserWorkStatus driverUserWorkStatus = driverUserWorkStatuses.get(0);

        driverUserWorkStatus.setWorkStatus(workStatus);
        driverUserWorkStatus.setGmtCreate(localDateTime);
        driverUserWorkStatus.setGmtModified(localDateTime);

        driverUserWorkStatusMapper.updateById(driverUserWorkStatus) ;
        return ResponseResult.success(" ") ;
    }
}
